Main site

Built-in Modules > searchCustomer Function

searchCustomer Function

Overview

The searchCustomer function is an asynchronous tool designed to search and retrieve customer details based on address and full name information contained within the DATA object.

Function Definition

async function searchCustomer(DATA) {
  // Function to search for customer details
}

Arguments

  • DATA (Object): The initial DATA JSON object provided to the calculateShippingRates function.

Usage Example

const customers = await searchCustomer(DATA);

In this example, searchCustomer is used to find customers whose details match the 'address_1' and 'city' fields from the input 'DATA' JSON object. The search is further refined using the first and last name fields from the same 'DATA' object.

Sample Output

customers = [
  { 
    "id": 7286464086326,
    "email": "[email protected]",
    "first_name": "John",
    "last_name": "Doe",
    "tags": "vip_customer, wholesale_customer"
  },
  // ... additional customer objects
];

Notes

  • The function searches for a customer using their addresses and full name in the cart. If the address provided in the cart is different from the customer's stored details in your store, the function will not be able to find the customer.
  • The function asynchronously searches and returns a list of customer objects, each containing details like ID, email, first and last name, and any associated tags.
  • This functionality is particularly useful in personalized shipping and customer management strategies.